package written.test;

import java.util.*;

/**
 * @Author: Dang Qi
 * @Date: 2021/4/4  10:37
 * @Description:
 */
public class MeiQ2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        Set<Integer> set = new HashSet<>();
        int weidu = 1;
        int jingdu = 0;
        for(int i = 0; i < n; i++){
            int type = sc.nextInt();
            int d = sc.nextInt();
            if(type==1){
                jingdu++;
            }else{
                weidu++;
            }
        }
       jingdu = jingdu == 0 ? 1 : jingdu;

        int ans = 2* jingdu * weidu;
        System.out.println(ans);
    }
}
